Skip to content

Fix sketch new default overwriting behavior #1993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 29, 2022

Conversation

MatteoPologruto
Copy link
Contributor

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?

Code imperfection fix

What is the current behavior?

Running arduino-cli sketch new . from a sketch directory overwrites an already existing .ino sketch file by default.

What is the new behavior?

It is no longer possible to overwrite an existing .ino sketch file in the above-mentioned way. Doing so, raises an error. It is, however, possible to force that behavior using the -f | --overwrite flag.

Does this PR introduce a breaking change, and is titled accordingly?

No

@MatteoPologruto MatteoPologruto added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Nov 29, 2022
@MatteoPologruto MatteoPologruto self-assigned this Nov 29, 2022
@umbynos umbynos linked an issue Nov 29, 2022 that may be closed by this pull request
Running "arduino-cli sketch new ." from a sketch directory overwrites an existing .ino sketch file, without asking for confirmation. This fix introduces a check to verify if the specified path already
contains a .ino sketch file. If it does, an error is returned, otherwise a new sketch is created as usual.
Using the "--overwrite" flag, allows to create a new sketch overwriting an existing one.
Copy link
Contributor

@umbynos umbynos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

Comment on lines +1773 to +1774
// be treated as read-only. This status is determined by the presence of a
// `.development` file in the library root directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from #1962

@MatteoPologruto MatteoPologruto merged commit ab73719 into arduino:master Nov 29, 2022
@MatteoPologruto MatteoPologruto deleted the sketch-new-fix branch November 29, 2022 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"sketch new ." overwriting sketch without confirmation
2 participants